<?php get_header(); ?>
<!--end header-->
<div class="span-16" id="main-content">

    <h3 class="label-title">Nhà trọ - <?php single_cat_title(); ?></h3>
    <?php
    /*
     *     Query Nhà Trọ information - display numbers of latest Nhà Trọ
     */


    if(have_posts()) : while(have_posts()) : the_post(); ?>
        <?php
        /*
        * Get important information
        */
        $the_id = get_the_id();
        $diachi = get_post_meta($the_id,'_diachi',true);
        //$dientich = get_post_meta($the_id,'_dientich',true);
        $gioitinh = get_post_meta($the_id,'_gioitinh',true);
        $ghichu = get_post_meta($the_id,'_ghichu',false);
        $phongtrong = get_post_meta($the_id,'_phongtrong',true);
        /*
        * Price Information
        */
        $giaphong = get_post_meta($the_id,'_giaphong',true);
        $giadien = get_post_meta($the_id,'_giadien',true);
        //$gianuoc = get_post_meta($the_id,'_gianuoc',false);
        //$chiphikhac = get_post_meta($the_id,'_chiphikhac',false);

        /*
        * noi quy
        */
        //$noiquy = get_post_meta($the_id,'_noiquy',true);

        if(strcmp($gioitinh,'nam') == 0) $gioitinh = 'Nam';
        elseif(strcmp($gioitinh,'nu') == 0) $gioitinh = 'Nữ';
        else $gioitinh = "Nam & Nữ";

        ?>

        <div class="span-16 item">
            <div class="span-16">
                <div class="title span-11">
                    <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
                </div>
                <div class="price span-5 last">
                    <h3 class="price"><?php echo $giaphong; ?> / tháng</h3>
                </div>
            </div>

            <?php include('post-meta.php'); ?>
            <div class="span-4 thumbnail">
                <?php
                /*
                * Display thumbnail
                */
                if ( has_post_thumbnail() )
                    the_post_thumbnail( 'thumbnail' );
                else echo 'Hình chưa được tải lên';
                ?>
            </div>
            <div class="span-12 last">
                <ul class="properties list">
                    <li class="location"><span>Địa điểm: </span><?php echo $diachi; ?></li>
                    <li class="empty-room"><span>Số phòng trống hiện tại: </span><?php echo $phongtrong; ?></li>
                    <li class="location"><span>Phòng dùng cho: </span><?php echo $gioitinh; ?></li>
                    <?php if(!empty($ghichu) && strcmp(trim($ghichu[0][0]),'') != 0) { ?>
                    <li class="item-note"><span>Ghi chú:</span>
                        <ul class="notes">
                            <?php foreach($ghichu[0] as $value) {
                            echo "<li>$value</li>";
                        }?>
                        </ul>
                    </li>
                    <?php } ;?>
                </ul><!--end list properties-->
                <p><a href="<?php the_permalink(); ?>" class="item-readmore">Xem chi tiết</a></p>
            </div>
        </div><!--end item-->

        <?php endwhile; else: echo "Chưa có nhà trọ được đăng!"; endif; ?>
    <?php wp_reset_query(); ?>

    <!--include bottom pagination-->
    <?php include ('bot-nav.php'); ?>

</div><!--end main-content-->
<!--begin sidebar-->
<?php get_sidebar(); ?>
<!--end sidebar-->
<!--begin footer-->
<?php get_footer(); ?>
<!--end footer-->